luci-app-statistics: fix prepare values from list vlaues
authorAleksey Kolosov <[email protected]>
Fri, 15 Nov 2024 07:42:55 +0000 (10:42 +0300)
committerPaul Donald <[email protected]>
Thu, 28 Nov 2024 20:18:33 +0000 (21:18 +0100)
If UCI store values as a list instead of an option, conversation for the
collectd configuration is not work correctly. This is due to the use of
a DynamicList type element in the UI (for example, for the RRATimespans
field). For this function argument val receives as array instead of a
string, so no additional conversion is required.

Signed-off-by: Aleksey Kolosov <[email protected]>
applications/luci-app-statistics/root/usr/libexec/stat-genconfig

index 130f8f3876149221bc094d194de372ef44eebeb9..0d6bd6704f69a4812e60808e38e2ce568d62e39d 100755 (executable)
@@ -58,7 +58,7 @@ function parse_units(ustr) {
 
 const preprocess = {
        RRATimespans: function(val) {
-               return join(' ', map(split(val, /\s+/), parse_units));
+               return join(' ', map(type(val) == 'array' ? val :  split(val, /\s+/), parse_units));
        }
 };